<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
package <xsl:value-of select="Schema/@NameSpace" />;

import System.*;
import System.Data.*;
import <xsl:value-of select="Schema/@EntityNameSpace" />.*;
import <xsl:value-of select="Schema/@DataAccessNameSpace" />.*;

public class <xsl:value-of select="Schema/@TableName" />Biz
{
	/**
	 * 添加一条记录
	 */
	public static void Add<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
	{
		<xsl:value-of select="Schema/@TableName" />Insert obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Insert();
		obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
		obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();<xsl:for-each select="Schema/Columns[IS_IDENTITY='1']">
		obj<xsl:value-of select="/Schema/@TableName" />.<xsl:value-of select="COLUMN_NAME" /> = obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" />;
		</xsl:for-each>
	}

	/**
	 * 查询<xsl:value-of select="Schema/@TableName" />表的所有信息
	 */
	public static DataTable GetAll<xsl:value-of select="Schema/@TableName" />()
	{
		<xsl:value-of select="Schema/@TableName" />SelectAll obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectAll();
		return obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable();
	}<xsl:if test="Schema/@IfHavePK=1">

	/**
	 * 修改一条记录
	 */
	public static void Update<xsl:value-of select="Schema/@TableName" />(<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" />)
	{
		<xsl:value-of select="Schema/@TableName" />Update obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Update();
		obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />);
		obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();
	}

	/**
	 * 删除一条记录
     */
	public static void Delete<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
	{
		<xsl:value-of select="Schema/@TableName" />Delete obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />Delete();<xsl:for-each select="Schema/Columns[IS_PK='1']">
		obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
		obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery();
	}

	/**
	 * 根据主键获取一条记录
     */
	public static <xsl:value-of select="Schema/@TableName" /> Get<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']"><xsl:value-of select="concat(LANGUAGE_TYPE,' ',COLUMN_NAME)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
	{
		<xsl:value-of select="Schema/@TableName" />SelectByPk obj<xsl:value-of select="Schema/@TableName" />DAL = new <xsl:value-of select="Schema/@TableName" />SelectByPk();
		<xsl:value-of select="Schema/@TableName" /> obj<xsl:value-of select="Schema/@TableName" /> = new <xsl:value-of select="Schema/@TableName" />();<xsl:for-each select="Schema/Columns[IS_PK='1']">
		obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" />;</xsl:for-each>
		obj<xsl:value-of select="Schema/@TableName" />.MetaDataTable = obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable();
		return obj<xsl:value-of select="Schema/@TableName" />;
	}</xsl:if>
}</xsl:template>
</xsl:stylesheet>